home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 187_01 / get_uniq.c < prev    next >
C/C++ Source or Header  |  1985-12-28  |  1KB  |  44 lines

  1. /*@*****************************************************/
  2. /*@                                                    */
  3. /*@ get_uniq - returns a unique file name built from   */
  4. /*@        the date and time.  The file name is mmdd   */
  5. /*@        from the date and hhmm from the time.       */
  6. /*@                                                    */
  7. /*@   Usage:     get_uniq(buffer);                     */
  8. /*@       where buffer is a 9-byte or more area.       */
  9. /*@   NOTE: The extension must be added by the caller. */
  10. /*@      (I.E. strncat(get_uniq(buf), ".LOG");         */
  11. /*@                                                    */
  12. /*@   Returns a pointer to the buffer.                 */
  13. /*@                                                    */
  14. /*@*****************************************************/
  15.  
  16.  
  17. char *get_uniq(buffer)
  18. char *buffer;
  19. {
  20.     char date[9], time[9];
  21.     int i;
  22.  
  23.     dates(date);
  24.     times(time);
  25.  
  26.     buffer[0] = date[0];        /* mm */
  27.     buffer[1] = date[1];
  28.     buffer[2] = date[3];        /* dd */
  29.     buffer[3] = date[4];
  30.     buffer[4] = time[0];        /* hh */
  31.     buffer[5] = time[1];
  32.     buffer[6] = time[3];        /* mm */
  33.     buffer[7] = time[4];
  34.  
  35.     buffer[8] = '\0';
  36.  
  37.     for (i=0; buffer[i]; i++)        /* prevent imbedded spaces */
  38.         if (buffer[i] == ' ')
  39.             buffer[i] = '0';
  40.  
  41.     return buffer;
  42.  
  43. }
  44.